package com.neutech.neusys.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neutech.neusys.mapper.ConstantItemMapper;
import com.neutech.neusys.mapper.ConstantTypeMapper;
import com.neutech.neusys.mapper.DeptMapper;
import com.neutech.neusys.mapper.RegistLevelMapper;
import com.neutech.neusys.mapper.UserMapper;
import com.neutech.neusys.service.UserService;
import com.neutech.po.ConstantItem;
import com.neutech.po.ConstantType;
import com.neutech.po.Dept;
import com.neutech.po.RegistLevel;
import com.neutech.po.User;
import com.neutech.vo.ToAddUserVo;




@Service
public class UserServiceImpl implements UserService{
	@Autowired
	private UserMapper userMapper;
	@Autowired
	private DeptMapper deptMapper;
	@Autowired
	private RegistLevelMapper registLevelMapper;
	@Autowired
	private ConstantItemMapper constantItemMapper;
	@Autowired
	private ConstantTypeMapper constantTypeMapper;
	/**
	 * 增加用户
	 * @param:用户对象
	 * @return：添加成功==1，添加失败==0
	 */
	/**
	 * 添加用户界面出现前，要查询信息，填充下拉列表
	 * 科室、用户类别、挂号级别、医生职称
	 * @return：添加成功==1，添加失败==0
	 */
	@Override
	public ToAddUserVo toAddUser() {
		List<Dept> deptList = deptMapper.queryAll();//科室
		List<ConstantType> userList = constantTypeMapper.queryAll();//用户类别
		List<RegistLevel> regList = registLevelMapper.queryAll();//挂号级别
		List<ConstantItem> docList = constantItemMapper.queryAll();//医生职称
		ToAddUserVo vo = new ToAddUserVo();
		vo.setDeptList(deptList);
		vo.setRegList(regList);
		vo.setDocList(docList);
		vo.setUserList(userList);
		return vo;
	}
	@Override
	public User addNewUser(Map<String, Object> user) {
		return userMapper.addNewUser(user);
	}
	@Override
	public int delUserById(int id) {
		return userMapper.delUserById(id);
	}
	@Override
	public int updateUser(User user) {
		return userMapper.updateUser(user);
	}
	@Override
	public List<User> queryAllUser() {
		// TODO Auto-generated method stub
		return userMapper.queryAllUser();
	}
}
